require 'rho/rhocontroller'
require 'helpers/browser_helper'

class TeaController < Rho::RhoController
  include BrowserHelper

  #GET /Tea
  def index
    @teas = Tea.find(:all)
    render :back => '/app'
  end

  # GET /Tea/{1}
  def show
    @tea = Tea.find(@params['id'])
    if @tea
      render :action => :show, :back => url_for(:action => :index)
    else
      redirect :action => :index
    end
  end

  # GET /Tea/new
  def new
    @tea = Tea.new
    render :action => :new, :back => url_for(:action => :index)
  end

  # GET /Tea/{1}/edit
  def edit
    @tea = Tea.find(@params['id'])
    if @tea
      render :action => :edit, :back => url_for(:action => :index)
    else
      redirect :action => :index
    end
  end

  # POST /Tea/create
  def create
    @tea = Tea.create(@params['tea'])
    redirect :action => :index
  end

  # POST /Tea/{1}/update
  def update
    @tea = Tea.find(@params['id'])
    @tea.update_attributes(@params['tea']) if @tea
    redirect :action => :index
  end

  # POST /Tea/{1}/delete
  def delete
    @tea = Tea.find(@params['id'])
    @tea.destroy if @tea
    redirect :action => :index  end
end
